﻿using System;
using System.Collections.Generic;
using System.Linq;
using InvoiceProject.Enums;
using InvoiceProject.Models;
using System.Text;

namespace InvoiceProject.Tests
{
    public class ModelGenerator
    {




        public static Address GetTestAddress()
        {
            
            return new Address
                       {
                           AddressLine1 = "44 Jolly Road",
                           AddressLine2 = "LakeSide",
                           PostCode = 2177,
                           State = "NSW",
                           Suburb = "Belconnen",
                       };
        }


        public static LookupTaxCountry GetAustralianTaxCountry()
        {
            return new LookupTaxCountry {Country = Country.AUS, TaxRate = .1M};
        }



        public static List<InvoiceItem> GetInvoiceItemList(int HowMany)
        {
            Random rand = new Random();
            List<InvoiceItem> itemList = new List<InvoiceItem>();

            for (int i = 1; i < HowMany; i++)
            {
                itemList.Add(new InvoiceItem {Quantity = rand.Next(1, 999), Rate = rand.Next(1, 200)});
            }

            return itemList;
        }

        public static Customer GetCustomer()
        {
            return new Customer
                       {
                           BusinessId = 43,
                           Email = "Customer@email.com",
                           LastName = "CustomerLast",
                           FirstName = "FirstName",
                       };
        }

        public static Invoice GetInvoice()
        {
            Random rand = new Random();
            return new Invoice
                       {
                           Customer = GetCustomer(),
                           Business = GetTestBusiness(),
                           InvoiceDate = DateTime.Now,
                           InvoiceItems = GetInvoiceItemList(rand.Next(4, 12)),
                          // DateCreated = DateTime.Now,
                           DateModified = DateTime.Now,
                           //UserCreated = "Jo",
                           UserModified = "Smith"

                       };
        }


        public static Quote GetQuote()
        {
            Random rand = new Random();
            return new Quote
                       {
                           QuoteDate = DateTime.Now,
                           ExpiryDate = DateTime.Now.AddDays(50),
                           Customer = GetCustomer(),
                           Business = GetTestBusiness(),
                           InvoiceDate = DateTime.Now,
                           InvoiceItems = GetInvoiceItemList(rand.Next(4, 12)),
                           // DateCreated = DateTime.Now,
                           DateModified = DateTime.Now,
                           //UserCreated = "Jo",
                           UserModified = "Smith"
                       };


        }

        public static Business GetTestBusiness()
            {
                return new Business
                           {
                               ABN = "1234567912",
                               AccountType = AccountType.Free,
                               Address = GetTestAddress(),
                               Email = "BusinessName@BusinessName.com.au",
                               LookupTaxCountry = GetAustralianTaxCountry(),
                               Phone = "98209820",
                               UserName = "JOE1234"

                           };


            }
        }
    
}
